using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Watson.Core.Tools;
using ITOMMS.Entity;

namespace ITOMMS.Web.Knowledge
{
    public partial class ArticleView : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    VwKnowledgeEntity article = new Entity.VwKnowledgeEntity();
                    article = article.FindEntity("ID="+int.Parse(Request.QueryString["id"]));
                    if (article != null)
                    {
                        lblTitle.Text = article.Title;
                        lblContent.Text = article.Content;
                        lblClassName.Text = article.ClassName;
                        lblCreateDate.Text = article.CreateDate.ToString();
                        lblCreateBy.Text = GetArticlAuthor(article.CreateBy.ToString());
                    }

                    if (ViewState["Entity"] != null)
                    {
                        article = ViewState["Entity"] as VwKnowledgeEntity;
                    }

                    //article.ViewNum += 1;
                    //article.Update();
                }
            }
        }

        public string GetArticlAuthor(string param)
        {
            string result = "";

            VwUserEntity user = new Entity.VwUserEntity();
            user = user.FindEntity("ID=" + param);
            if (user != null)
            {
                result = user.RealName;
            }
            return result;
        }
    }
}
